using TripleA.Core.Interfaces;
using TripleA.Core.Interfaces.Entities;

namespace TripleA.Core.Extensions.Process
{
    public static class ProcessExtensions
    {
        public static IPipelineConfig<T> IsExeRunning<T>(this IPipelineConfig<T> config, string exeFilename, bool shouldBeRunning = true)
            where T : Context
        {
            config.RunStep(new CheckProcessIsRunningStep<T>
                               {
                                   ExeFilename = exeFilename,
                                   ShouldBeRunning = shouldBeRunning
                               });
            return config;
        }        

        public static IPipelineConfig<T> RunProcess<T>(this IPipelineConfig<T> config, string exeFilePath, string args = null, int? waitForExit = null)
            where T : Context
        {
            config.RunStep(new RunProcessStep<T>
                               {
                                   ExeFilePath = exeFilePath,
                                   Args = args,
                                   WaitForExit = waitForExit
                               });
            return config;
        }          
    }
}